unsigned long i = 0;
an1_waypoint_record* rec = NULL;
waypoint* wpt_tmp;
- char* icon = NULL;
char* url = NULL;
+ char* icon = NULL;
ReadShort(f);
count = ReadLong(f);
for (i = 0; i < count; i++) {
wpt_tmp->description = xstrdup(rec->name);
if (rec->url) {
wpt_tmp->AddUrlLink(rec->url);
+#if NEW_STRINGS
+ } else {
+ int u = wpt_tmp->description.indexOf("{URL=");
+ QString us = wpt_tmp->description.mid(u);
+ wpt_tmp->AddUrlLink(us);
+ }
+#else
} else if (NULL != (url=strstr(wpt_tmp->description, "{URL="))) {
*url = '\0';
url += 5;
url[strlen(url)-1] = '\0';
wpt_tmp->AddUrlLink(url);
}
+#endif
if (rec->image_name) {
wpt_tmp->icon_descr = xstrdup(rec->image_name);
rec->name = xstrdup(wpt->description);
if (!nogc && wpt->gc_data->id) {
+#if NEW_STRINGS
+ char* extra = (char*) xmalloc(25 + wpt->gc_data->placer.length() + wpt->shortname.length());
+#else
char* extra = (char*) xmalloc(25 + strlen(wpt->gc_data->placer.toUtf8().data()) + strlen(wpt->shortname));
+#endif
sprintf(extra, "\r\nBy %s\r\n%s (%1.1f/%1.1f)",
wpt->gc_data->placer.toUtf8().data(),
CSTRc(wpt->shortname), wpt->gc_data->diff/10.0,
xfree(extra);
rec->url = xstrdup(l.url_.toUtf8().data());
}
-
+#if NEW_STRINGS
+ if (!wpt->notes.isEmpty()) {
+#else
if (wpt->notes) {
+#endif
if (rec->comment) {
xfree(rec->comment);
}
wpt_tmp->latitude = DecodeOrd(vert->lat);
wpt_tmp->longitude = -DecodeOrd(vert->lon);
wpt_tmp->shortname = (char*) xmalloc(7);
+#if NEW_STRINGS
+ wpt_tmp->shortname = QString().sprintf("\\%5.5lx", rtserial++);
+#else
sprintf(wpt_tmp->shortname, "\\%5.5lx", rtserial++);
fs_chain_add(&wpt_tmp->fs,
(format_specific_data*)vert);
+#endif
route_add_wpt(rte_head, wpt_tmp);
}
}
#define FREAD_i32 gbfgetint32(fin)
#define FREAD_i16 gbfgetint16(fin)
#define FREAD_STR(a) gdb_fread_str(a,sizeof(a),fin)
+#if NEW_STRINGS
+#define FREAD_CSTR QString::fromLatin1(gdb_fread_cstr(fin))
+#else
#define FREAD_CSTR gdb_fread_cstr(fin)
+#endif
#define FREAD_CSTR_AS_QSTR gdb_fread_cstr_as_qstr(fin)
#define FREAD_DBL gbfgetdbl(fin)
#define FREAD_LATLON GPS_Math_Semi_To_Deg(gbfgetint32(fin))
static QString
gdb_fread_strlist(void)
{
- char* res = NULL;
+// char* res = NULL;
+ QString res;
int count;
count = FREAD_i32;
while (count > 0) {
+#if HUH
char* str = FREAD_CSTR;
if (str != NULL) {
if (*str && (res == NULL)) {
xfree(str);
}
}
+#else
+ QString str = FREAD_CSTR;
+ if (!str.isEmpty()) {
+ res = str;
+ }
+#endif
count--;
}
QString qres = res;
- xfree(res);
+// xfree(res);
return qres;
}
gdb_find_wayptq(const queue* Q, const waypoint* wpt, const char exact)
{
queue* elem, *tmp;
+#if NEW_STRINGS
+ QString name = wpt->shortname;
+#else
const char* name = wpt->shortname;
+#endif
QUEUE_FOR_EACH(Q, elem, tmp) {
waypoint* tmp = (waypoint*)elem;
+#if NEW_STRINGS
+ if (name.compare(tmp->shortname,Qt::CaseInsensitive) == 0) {
+#else
if (case_ignore_strcmp(name, tmp->shortname) == 0) {
+#endif
if (! exact) {
return tmp;
}
}
res = NULL;
+#if NEW_STRINGS
+ turn_point = (gdb_roadbook && (wpt_class > gt_waypt_class_map_point) && !tmp->description.isEmpty());
+#else
turn_point = (gdb_roadbook && (wpt_class > gt_waypt_class_map_point) && tmp->description);
+#endif
if (turn_point || (gdb_via == 0) || (wpt_class < gt_waypt_class_map_point)) {
res = waypt_dupe(tmp);
route_add_wpt(rte, res);
gmsd = garmin_fs_alloc(-1);
fs_chain_add(&res->fs, (format_specific_data*) gmsd);
-
res->shortname = FREAD_CSTR;
#if GDB_DEBUG
sn = xstrdup(nice(res->shortname));
/* VERSION DEPENDENT CODE */
if (gdb_ver <= GDB_VER_2) {
- char* temp;
FREAD(buf, 2); /* ?????????????????????????????????? */
waypt_flag = FREAD_C;
FREAD(buf, 2);
}
- temp = FREAD_CSTR; /* undocumented & unused string */
+ QString junk = FREAD_CSTR; /* undocumented & unused string */
#if GDB_DEBUG
DBG(GDB_DBG_WPTe, temp)
printf(MYNAME "-wpt \"%s\" (%d): Unknown string = %s\n",
sn, wpt_class, nice(temp));
#endif
- if (temp) {
- xfree(temp);
- }
QString linky = FREAD_CSTR_AS_QSTR;
UrlLink l(linky);
FREAD(buf, 5); /* instruction depended */
res->description = FREAD_CSTR; /* instruction */
-
url_ct = FREAD_i32;
for (i = url_ct; (i); i--) {
QString str = FREAD_CSTR_AS_QSTR;
GMSD_SETSTR(country, gt_get_icao_country(str));
}
}
-
+#if NEW_STRINGS
+ if (gdb_roadbook && (wpt_class > gt_waypt_class_map_point) && !res->description.isEmpty()) {
+#else
if (gdb_roadbook && (wpt_class > gt_waypt_class_map_point) && res->description) {
+#endif
wpt_class = gt_waypt_class_user_waypoint;
GMSD_SET(wpt_class, wpt_class);
#ifdef GMSD_EXPERIMENTAL
}
if ((wpt->latitude < -90) || (wpt->latitude > 90.0))
+#if NEW_STRINGS
+ fatal("Invalid latitude %f in waypoint %s.\n",
+ lat_orig, !wpt->shortname.isEmpty() ? CSTRc(wpt->shortname) : "<no name>");
+ if ((wpt->longitude < -180) || (wpt->longitude > 180.0))
+ fatal("Invalid longitude %f in waypoint %s.\n",
+ lon_orig, !wpt->shortname.isEmpty() ? CSTRc(wpt->shortname) : "<no name>");
+#else
fatal("Invalid latitude %f in waypoint %s.\n",
lat_orig, wpt->shortname ? CSTRc(wpt->shortname) : "<no name>");
if ((wpt->longitude < -180) || (wpt->longitude > 180.0))
fatal("Invalid longitude %f in waypoint %s.\n",
lon_orig, wpt->shortname ? CSTRc(wpt->shortname) : "<no name>");
+#endif
}
/*-----------------------------------------------------------------------------*/
static void
write_waypoint(
+#if NEW_STRINGS
+ const waypoint* wpt, const QString& shortname, garmin_fs_t* gmsd,
+#else
const waypoint* wpt, const char* shortname, garmin_fs_t* gmsd,
+#endif
const int icon, const int display)
{
char zbuf[32], ffbuf[32];
FWRITE_LATLON(wpt->latitude); /* latitude */
FWRITE_LATLON(wpt->longitude); /* longitude */
FWRITE_DBL(wpt->altitude, unknown_alt); /* altitude */
+#if NEW_STRINGS
+ if (!wpt->notes.isEmpty()) {
+#else
if (wpt->notes) {
+#endif
FWRITE_CSTR(wpt->notes);
} else {
FWRITE_CSTR(wpt->description);
} else { /* if (gdb_ver > GDB_VER_3) */
int cnt;
// url_link* url_next;
- const char* str;
+// const char* str;
+ QString str;
if (wpt_class < gt_waypt_class_map_point) { /* street address */
str = GMSD_GET(addr, "");
/* GBD doesn't have a native description field */
/* here we misuse the instruction field */
-
+#if 1
+ QString d = wpt->description;
+ if (wpt->description == wpt->shortname) {
+ d.clear();
+ }
+ if (str == wpt->notes) {
+ d.clear();
+ }
+ FWRITE_CSTR(d); /* instruction */
+#else
str = wpt->description;
if (str && (strcmp(str, wpt->shortname) == 0)) {
str = NULL;
str = NULL;
}
FWRITE_CSTR(str); /* instruction */
+#endif
cnt = 0;
cnt += wpt->url_link_list_.size();
}
static void
-write_route(const route_head* rte, const char* rte_name)
+write_route(const route_head* rte, const QString& rte_name)
{
bounds bounds;
int points, index;
}
static void
-write_track(const route_head* trk, const char* trk_name)
+write_track(const route_head* trk, const QString& trk_name)
{
queue* elem, *tmp;
int points = ELEMENTS(trk);
}
/*-----------------------------------------------------------------------------*/
-
+#if NEW_STRINGS
+#else
static char
str_not_equal(const char* s1, const char* s2)
{
return 0;
}
}
+#endif
static void
write_waypoint_cb(const waypoint* refpt)
gbfile* fsave;
/* do this when backup always happens in main */
-
+#if NEW_STRINGS
+// but, but, casting away the const here is wrong...
+ ((waypoint*)refpt)->shortname = refpt->shortname.trimmed();
+#else
rtrim(((waypoint*)refpt)->shortname);
+#endif
test = gdb_find_wayptq(&wayptq_out, refpt, 1);
if (refpt->HasUrlLink() && test && test->HasUrlLink() && route_flag == 0) {
}
if ((test != NULL) && (route_flag == 0)) {
+#if NEW_STRINGS
+ if (test->notes != refpt->notes) {
+#else
if (str_not_equal(test->notes, refpt->notes)) {
+#endif
test = NULL;
}
}
if (test == NULL) {
int icon, display, wpt_class;
+#if NEW_STRINGS
+ QString name;
+#else
char* name;
+#endif
waypoint* wpt = waypt_dupe(refpt);
gdb_check_waypt(wpt);
name = wpt->shortname;
+#if NEW_STRINGS
+ if (global_opts.synthesize_shortnames || name.isEmpty()) {
+ name = wpt->notes;
+ if (name.isEmpty()) {
+ name = wpt->description;
+ }
+ if (name.isEmpty()) {
+ name = wpt->shortname;
+ }
+#else
if (global_opts.synthesize_shortnames || (*name == '\0')) {
name = wpt->notes;
if (!name) {
if (!name) {
name = wpt->shortname;
}
+#endif
}
name = mkshort(short_h, name);
+#if NEW_STRINGS
+#warning WTH is THIS? Have some dead beef instead.
+ wpt->extra_data = (void*) 0xdeadbeef;
+#else
wpt->extra_data = (void*)name;
+#endif
write_waypoint(wpt, name, gmsd, icon, display);
finalize_item(fsave, 'W');
write_route_cb(const route_head* rte)
{
gbfile* fsave;
- char* name;
char buf[32];
if (ELEMENTS(rte) <= 0) {
return;
}
+ QString name;
if (rte->rte_name == NULL) {
snprintf(buf, sizeof(buf), "Route%04d", rte->rte_num);
name = mkshort(short_h, buf);
fout = ftmp;
write_route(rte, name);
finalize_item(fsave, 'R');
-
- xfree(name);
}
static void
write_track_cb(const route_head* trk)
{
gbfile* fsave;
- char* name;
+ QString name;
char buf[32];
if (ELEMENTS(trk) <= 0) {
write_track(trk, name);
finalize_item(fsave, 'T');
- xfree(name);
}
/*-----------------------------------------------------------------------------*/
addrlen = le_read16(&record[obase]);
cmtlen = le_read16(&record[obase+2+addrlen]);
-
+#if NEW_STRINGS
+ wpt_tmp->shortname = "booger";
+ wpt_tmp->notes = "goober";
+#else
wpt_tmp->shortname = (char*) xmalloc(addrlen+1);
wpt_tmp->shortname[addrlen]='\0';
wpt_tmp->notes = (char*) xmalloc(cmtlen+1);
memcpy(wpt_tmp->shortname,
record+obase+2,
addrlen);
+#endif
} else {
+#if NEW_STRINGS
+ wpt_tmp->shortname = QString().sprintf("\\%5.5x", serial++);
+#else
wpt_tmp->shortname = (char*) xmalloc(7);
sprintf(wpt_tmp->shortname, "\\%5.5x", serial++);
+#endif
}
if (control == 2) {
waypt_add(wpt_tmp);
route_add_head(track_head);
}
} // end if
+#if NEW_STRINGS
+ if (track_head->rte_name.isEmpty()) {
+ track_head->rte_name = "I made this up";
+ }
+#else
if (!track_head->rte_name) {
track_head->rte_name =
(char*)xmalloc(stringlen+1);
(const char*) record+2, stringlen);
track_head->rte_name[stringlen] = '\0';
}
+#endif
}
if (timesynth) {
wpt_tmp->latitude = lat;
wpt_tmp->longitude = -lon;
if (stringlen && ((coordcount>1) || count)) {
+#if NEW_STRINGS
+ wpt_tmp->shortname = QString(((char*)record)+2);
+#else
wpt_tmp->shortname = (char*) xmalloc(stringlen+1);
wpt_tmp->shortname[stringlen] = '\0';
memcpy(wpt_tmp->shortname,
((char*)record)+2,
stringlen);
+#endif
} else {
+#if NEW_STRINGS
+ wpt_tmp->shortname = QString().sprintf("\\%5.5x", serial++);
+#else
wpt_tmp->shortname = (char*) xmalloc(7);
sprintf(wpt_tmp->shortname, "\\%5.5x",
serial++);
+#endif
}
if (timesynth) {
if (!first) {